# -*- coding: utf-8 -*-

import json
from django.conf.urls import *
from django.http import HttpResponse
from django.shortcuts import render
from testdemo.com.dao.SysInfoDao import SysInfoDao

def mointer(request):
    list = [];
    context = {};
    context['list'] = list;
    return render(request, 'mointer.html', context)
def moninfo(request):
    s = SysInfoDao("select percent from memca limit 14");

    list = ['cpu使用率','内存使用','磁盘空间']
    cpu_info_list = [120, 132, 101, 134, 90, 230, 210,120, 132, 101, 134, 90, 230, 210]
    cpu_info = {"name":"cpu使用率","cpu_info_list":cpu_info_list};
    me_info_list = s.query();#[220, 182, 191, 234, 290, 330, 310];
    me_info = {"name": "内存使用", "me_info_list": me_info_list};
    disk_info_list = [150, 232, 201, 154, 190, 330, 410,120, 132, 101, 134, 90, 230, 210]
    disk_info = {"name": "磁盘空间", "disk_info_list": disk_info_list};

    xList = ['11:10','11:20','11:30','11:40','11:50','12:00','12:10','12:20','12:30','12:40','12:50','13:00','13:10','13:20'];
    response_data = {}
    response_data['list'] = list
    response_data['cpu_info'] = cpu_info
    response_data['me_info'] = me_info
    response_data['disk_info'] = disk_info
    response_data['xList'] = xList
    return HttpResponse(json.dumps(response_data), content_type="application/json")